﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.OleDb;

namespace Book
{
    public partial class Form4_4 : Form
    {
        public Form4_4()
        {
            InitializeComponent();
        }

        private void 修改密码_Click(object sender, EventArgs e)
        {
            if (radioButton1.Checked)
            {
                if (textBox1.Text == UserHelper.UserName)
                {
                    if (textBox2.Text == textBox3.Text)
                    {
                        OleDbConnection DBconnect = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\zAllstation\access\bookmanage.accdb");
                        DBconnect.Open();
                        string sqlcmd = string.Format("update reader set 密码='{0}' where 读者编号 ='{1}'", textBox2.Text, UserHelper.UserName);
                        OleDbCommand oleDbCommand = new OleDbCommand(sqlcmd, DBconnect);
                        int i = oleDbCommand.ExecuteNonQuery();
                        MessageBox.Show("密码修改成功!");
                        Form1 form1 = new Form1();
                        form1.Show();
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("密码错误！");
                    }
                }
                else
                {
                    MessageBox.Show("编号输入有误！");
                }
            }
            if (radioButton2.Checked)
            {
                if (textBox1.Text == UserHelper.UserName)
                {
                    if (textBox2.Text == textBox3.Text)
                    {
                        OleDbConnection DBconnect = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\zAllstation\access\bookmanage.accdb");
                        DBconnect.Open();
                        string sqlcmd = string.Format("update admin set 密码='{0}' where 编号 ='{1}'", textBox2.Text, UserHelper.UserName);
                        OleDbCommand oleDbCommand = new OleDbCommand(sqlcmd, DBconnect);
                        int i = oleDbCommand.ExecuteNonQuery();
                        MessageBox.Show("密码修改成功!");
                        Form1 form1 = new Form1();
                        form1.Show();
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("密码错误！");
                    }
                }
                else
                {
                    MessageBox.Show("编号输入有误！");
                }
            }

        }

        private void Form4_4_Load(object sender, EventArgs e)
        {

        }
    }
}
